package cn.ecut.dzy.mp.service.impl;

import cn.ecut.dzy.mp.domain.Orders;
import cn.ecut.dzy.mp.domain.User;
import cn.ecut.dzy.mp.mapper.OrdersMapper;
import cn.ecut.dzy.mp.mapper.UserMapper;
import cn.ecut.dzy.mp.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: mybatisplus
 * @description:
 * @author: DingZhenYun
 * @create: 2021-10-12 21:32
 **/

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private OrdersMapper ordersMapper;

    @Override
    public User test() {
        UserMapper userMapper = getBaseMapper();
        List<Orders> orders = ordersMapper.selectList(null);
        User user = userMapper.selectById(3);
        //查询用户对于的订单
        QueryWrapper<Orders> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",3);
        List<Orders> ordersList = ordersMapper.selectList(wrapper);
        return user;
    }
}
